package top.lshaci.learning.springboot.mqtt.controller;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lshaci.learning.springboot.mqtt.gateway.MqttGateway;

/**
 * MqttSendController
 *
 * @author liangxu
 */
@RestController
@AllArgsConstructor
@RequestMapping("/mqtt/send")
public class MqttSendController {

    private final MqttGateway mqttGateway;

    @GetMapping
    public String sendMqtt(String topic, String content) {
        mqttGateway.send(topic, content);
        return StrUtil.format("发送内容: {} 成功 ----" + "主题: {}", content, topic);
    }

}
